package com.aspose.cells;

import java.util.ArrayList;
import java.util.Collection;

class zbuk {
   private static String a = "[\\uFB50-\\uFDFF\\uFE70-\\uFEFF\\u0590-\\u05FF]+";
   private static final com.aspose.cells.b.c.a.za b = new com.aspose.cells.b.c.a.za(new String[]{".bmp", ".dib", ".rle", ".emf", ".jpg", ".jpeg", ".jpe", ".jfif", ".png", ".gif", ".tif", ".tiff"});

   static void a(com.aspose.cells.b.a.d.zm var0, com.aspose.cells.a.d.zl var1, ImageOrPrintOptions var2, int var3, int var4) throws Exception {
      float var5 = b((float)var3);
      float var6 = b((float)var4);
      ImageFormat var7 = var2.getImageFormat();
      com.aspose.cells.a.d.zm var25;
      if (var2.getSaveFormat() == 20) {
         com.aspose.cells.a.d.zgp var27 = new com.aspose.cells.a.d.zgp(var0);
         var25 = new com.aspose.cells.a.d.zm(var5, var6);
         var25.a(var1);
         var27.a((com.aspose.cells.a.d.zl)var25);
         var27.a();
         var0.b(0L);
      } else if (var2.getSaveFormat() == 22) {
         com.aspose.cells.a.d.zfp var26 = new com.aspose.cells.a.d.zfp(var2);
         var25 = new com.aspose.cells.a.d.zm(var5, var6);
         var25.a(var1);
         var26.a(var25, var0, var2.getEmbededImageNameInSvg());
         var26.a();
         var0.b(0L);
      } else if (var7 == ImageFormat.getEmf()) {
         zao.a(var1, var0, var2, var3, var4);
         var0.b(0L);
      } else {
         com.aspose.cells.b.a.b.za var8;
         if (var7 == ImageFormat.getTiff()) {
            var8 = null;

            try {
               var8 = a(var1, var2, var3, var4);
               zmq var9 = new zmq();
               var9.a(var0, var2, var8);
            } finally {
               if (var8 != null) {
                  var8.d();
               }

            }

         } else {
            if (var7 != ImageFormat.getBmp() && var7 != ImageFormat.getPng() && var7 != ImageFormat.getGif() && var7 != ImageFormat.getJpeg()) {
               var2.setImageFormat(ImageFormat.getBmp());
               var8 = a(var1, var2, var3, var4);

               try {
                  if (var8 == null) {
                     return;
                  }

                  var8.a(var0, var2.getImageFormat());
                  var0.b(0L);
               } finally {
                  if (var8 != null) {
                     var8.b();
                  }

               }
            } else {
               var8 = a(var1, var2, var3, var4);

               try {
                  if (var8 == null) {
                     return;
                  }

                  if (var7 == ImageFormat.getJpeg()) {
                     com.aspose.cells.a.d.zbn.a(var8, var0, (long)var2.getQuality());
                  } else {
                     var8.a(var0, var7);
                  }

                  var0.b(0L);
               } finally {
                  if (var8 != null) {
                     var8.b();
                  }

               }
            }

         }
      }
   }

   static com.aspose.cells.b.a.b.za a(com.aspose.cells.a.d.zl var0, ImageOrPrintOptions var1, int var2, int var3) throws Exception {
      int[] var4 = new int[]{1, 1};
      com.aspose.cells.b.a.b.za var5 = null;

      try {
         float var6 = (float)var1.getHorizontalResolution() / com.aspose.cells.a.d.zfq.a();
         float var7 = (float)var1.getVerticalResolution() / com.aspose.cells.a.d.zfq.a();
         int var8 = (int)((double)((float)var2 * var6) + 0.5D);
         int var9 = (int)((double)((float)var3 * var7) + 0.5D);
         var5 = new com.aspose.cells.b.a.b.za(var8, var9, var1.b());
         var4[0] = var5.m().b();
         var4[1] = var5.m().c();
         com.aspose.cells.b.a.b.zi var10 = com.aspose.cells.b.a.b.zi.a((com.aspose.cells.b.a.b.zj)var5);
         var10.b().setRenderingHints(var1.g);
         var10.a(3);
         var10.a(Color.getEmpty());
         var10.a(var6, var7);
         com.aspose.cells.a.d.zat var11 = new com.aspose.cells.a.d.zat();
         var11.a(var0, var10);
         var5.a((float)var1.getHorizontalResolution(), (float)var1.getVerticalResolution());
         var11.a();
         var10.e();
         return var5;
      } catch (Exception var12) {
         throw new CellsException(4, var12.getMessage());
      }
   }

   public static void a(String var0, ImageOrPrintOptions var1) throws Exception {
      String var2 = com.aspose.cells.b.a.d.zk.d(var0);
      if (var2 != null) {
         var2 = var2.toLowerCase();
      }

      if (".svg".equals(var2)) {
         var1.setSaveFormat(22);
         var1.setImageFormat(ImageFormat.getIcon());
      } else if (".xps".equals(var2)) {
         var1.setSaveFormat(20);
         var1.setImageFormat(ImageFormat.getIcon());
      } else {
         switch(b.a(var2)) {
         case 0:
         case 1:
         case 2:
            var1.setImageFormat(ImageFormat.getBmp());
            break;
         case 3:
            var1.setImageFormat(ImageFormat.getEmf());
            break;
         case 4:
         case 5:
         case 6:
         case 7:
            var1.setImageFormat(ImageFormat.getJpeg());
            break;
         case 8:
            var1.setImageFormat(ImageFormat.getPng());
            break;
         case 9:
            var1.setImageFormat(ImageFormat.getGif());
            break;
         case 10:
         case 11:
            var1.setImageFormat(ImageFormat.getTiff());
         }
      }

   }

   public static ImageFormat a(String var0, ImageFormat var1) {
      var0 = var0.toLowerCase();
      if (".png".equals(var0)) {
         return ImageFormat.getPng();
      } else if (".emf".equals(var0)) {
         return ImageFormat.getEmf();
      } else if (".gif".equals(var0)) {
         return ImageFormat.getGif();
      } else if (!".jpg".equals(var0) && !".jpeg".equals(var0) && !".jpe".equals(var0) && !".jfif".equals(var0)) {
         if (!".tiff".equals(var0) && !".tif".equals(var0)) {
            if (!".bmp".equals(var0) && !".dib".equals(var0) && !".rle".equals(var0)) {
               return var1 != null && var1 != ImageFormat.getIcon() && var1 != ImageFormat.getMemoryBmp() && var1 != ImageFormat.getWmf() && var1 != ImageFormat.getExif() ? var1 : ImageFormat.getBmp();
            } else {
               return ImageFormat.getBmp();
            }
         } else {
            return ImageFormat.getTiff();
         }
      } else {
         return ImageFormat.getJpeg();
      }
   }

   public static void a(com.aspose.cells.b.a.b.zo[] var0) {
      if (var0 != null) {
         for(int var1 = 0; var1 < var0.length; ++var1) {
            var0[var1] = new com.aspose.cells.b.a.b.zo(0.0F, 0.0F);
         }

      }
   }

   public static com.aspose.cells.b.a.b.zo a(com.aspose.cells.b.a.b.zo var0) {
      return new com.aspose.cells.b.a.b.zo(var0.d(), var0.e());
   }

   static int a(double var0) {
      return (int)Math.ceil(var0);
   }

   static int b(double var0) {
      return (int)Math.floor(var0);
   }

   static int c(double var0) {
      return (int)(var0 + 0.5D);
   }

   static void a(com.aspose.cells.b.a.b.zp[] var0) {
      if (var0[0].e() > var0[0].f()) {
         var0[0].a(var0[0].c() + (var0[0].e() - var0[0].f()) / 2);
         var0[0].c(var0[0].f());
      } else if (var0[0].f() > var0[0].e()) {
         var0[0].b(var0[0].d() + (var0[0].f() - var0[0].e()) / 2);
         var0[0].d(var0[0].e());
      }

   }

   static boolean a(com.aspose.cells.b.a.b.zp var0) {
      return var0.e() <= 0 || var0.f() <= 0;
   }

   static void b(com.aspose.cells.b.a.b.zp[] var0) {
      if (var0[0].e() < 0) {
         var0[0].c(0);
      }

      if (var0[0].f() < 0) {
         var0[0].d(0);
      }

   }

   public static float a(float var0) {
      return var0 * 72.0F / 96.0F;
   }

   public static float b(float var0) {
      return var0 * 72.0F / com.aspose.cells.a.d.zfq.a();
   }

   public static float d(double var0) {
      return (float)(var0 * (double)com.aspose.cells.a.d.zfq.a() / 72.0D);
   }

   public static com.aspose.cells.b.a.b.zq a(com.aspose.cells.b.a.b.zq var0) {
      int var1 = (int)((double)var0.f() + 0.5D);
      int var2 = (int)((double)var0.g() + 0.5D);
      int var3 = (int)((double)var0.h() + 0.5D);
      int var4 = (int)((double)var0.i() + 0.5D);
      return new com.aspose.cells.b.a.b.zq((float)var1, (float)var2, (float)var3, (float)var4);
   }

   static com.aspose.cells.b.a.b.zq b(com.aspose.cells.b.a.b.zp var0) {
      return new com.aspose.cells.b.a.b.zq((float)var0.c(), (float)var0.d(), (float)var0.e(), (float)var0.f());
   }

   static com.aspose.cells.b.a.b.zt a(com.aspose.cells.b.a.b.zs var0) {
      return new com.aspose.cells.b.a.b.zt((float)var0.b(), (float)var0.c());
   }

   static com.aspose.cells.b.a.b.zq b(com.aspose.cells.b.a.b.zq var0) {
      return new com.aspose.cells.b.a.b.zq(var0.f(), var0.g(), var0.h(), var0.i());
   }

   static com.aspose.cells.b.a.b.zp c(com.aspose.cells.b.a.b.zp var0) {
      return new com.aspose.cells.b.a.b.zp(var0.c(), var0.d(), var0.e(), var0.f());
   }

   static double e(double var0) {
      double var2 = Math.log10(var0);
      return var2;
   }

   static double f(double var0) {
      return Math.pow(10.0D, var0);
   }

   static int g(double var0) {
      char var2 = com.aspose.cells.b.a.ze.a(com.aspose.cells.b.a.c.zc.a().c());
      int var3 = 1;
      String var4 = "";
      String var5 = com.aspose.cells.b.a.zn.b(var0);
      int var6 = var5.indexOf("E");
      int var7 = var5.indexOf("e");
      int var9;
      if (var6 > 0 || var7 > 0) {
         String[] var8;
         if (var6 > 0) {
            var8 = com.aspose.cells.b.a.zv.d(var5, 'E');
         } else {
            var8 = com.aspose.cells.b.a.zv.d(var5, 'e');
         }

         if (var8[0].charAt(0) == '-') {
            var8[0] = var8[0].substring(1);
         }

         var9 = var8[0].indexOf(var2);
         int var10 = Math.abs(com.aspose.cells.b.a.ze.f(var8[1]));
         int var11;
         if (var9 > 0) {
            var4 = var8[0].substring(0, 0 + var9) + var8[0].substring(var9 + 1);
            if (var8[1].charAt(0) != '-') {
               while(var10 > 0) {
                  var4 = var4 + "0";
                  --var10;
               }
            } else {
               var11 = var10 - (var9 - 1);
               if (var11 <= 0) {
                  if (var11 < 0) {
                     var4 = var4.substring(0, 0 + var9 + var11) + var2 + var4.substring(var9 + var11);
                  }
               } else {
                  while(var11 > 0) {
                     var4 = "0" + var4;
                     --var11;
                  }

                  var4 = Character.toString(var4.charAt(0)) + var2 + var4.substring(1);
               }
            }
         } else {
            var4 = var8[0];
            if (var8[1].charAt(0) != '-') {
               while(var10 > 0) {
                  var4 = var4 + "0";
                  --var10;
               }
            } else {
               var11 = var10 - (var4.length() - 1);
               if (var11 <= 0) {
                  if (var11 < 0) {
                     var4 = var4.substring(0, 0 + var4.length() + var11) + var2 + var4.substring(var4.length() + var11);
                  }
               } else {
                  while(var11 > 0) {
                     var4 = "0" + var4;
                     --var11;
                  }

                  var4 = Character.toString(var4.charAt(0)) + var2 + var4.substring(1);
               }
            }
         }

         var5 = var4;
      }

      int var12 = var5.indexOf(var2, 0);
      if (var12 > 0) {
         for(var9 = var12 + 1; var9 < var5.length(); ++var9) {
            ++var3;
         }
      }

      return var3;
   }

   static int a(double... var0) {
      int var1 = 0;

      for(int var2 = 0; var2 < var0.length; ++var2) {
         int var3 = g(var0[var2]);
         if (var3 > var1) {
            var1 = var3;
         }
      }

      return var1;
   }

   static double a(double var0, double var2) {
      int var4 = g(var0);
      int var5 = g(var2);
      int var6 = var4 > var5 ? var4 : var5;
      return a(var0 - var2, var6);
   }

   static double a(double var0, int var2) {
      if (var2 > 15) {
         double var3 = var0 * Math.pow(10.0D, (double)(var2 - 15 - 1));
         double var5 = com.aspose.cells.b.a.zq.b(var3, 15);
         double var7 = var5 * Math.pow(10.0D, (double)(16 - var2));
         return var7;
      } else {
         return var2 == 15 ? var0 : com.aspose.cells.b.a.zq.b(var0, var2);
      }
   }

   static double b(double var0, double var2) {
      int var4 = g(var0);
      int var5 = g(var2);
      int var6 = var4 > var5 ? var4 : var5;
      return a(var0 + var2, var6);
   }

   static int h(double var0) {
      double var2 = e(var0);
      boolean var4 = true;
      if (var2 < 0.0D) {
         var4 = false;
      }

      var2 = Math.abs(var2);
      int var5 = b(var2);
      if ((double)var5 != var2) {
         ++var5;
      }

      if (!var4) {
         var5 = -var5;
      }

      return var5;
   }

   static DateTime a(double var0, boolean var2) {
      if (var0 > 2958465.99D) {
         return DateTime.b;
      } else {
         if (var2) {
            var0 += 1462.0D;
         }

         if (var0 < 60.0D) {
            ++var0;
         }

         return DateTime.b(var0);
      }
   }

   static double a(DateTime var0, boolean var1) {
      if (var1) {
         com.aspose.cells.b.a.zk var8 = com.aspose.cells.a.c.zk.e(var0, new DateTime(1904, 1, 1));
         double var9 = var8.c();
         return var9 < 0.0D ? -1.0D : var9;
      } else {
         DateTime var4 = new DateTime(1900, 3, 1);
         com.aspose.cells.b.a.zk var5 = com.aspose.cells.a.c.zk.e(var0, var4);
         DateTime var2;
         if (var5.c() > 0.0D) {
            var2 = new DateTime(1899, 12, 30);
         } else {
            var2 = new DateTime(1899, 12, 31);
         }

         DateTime var3 = new DateTime(9999, 12, 31, 23, 59, 59, 999);
         var5 = com.aspose.cells.a.c.zk.e(var3, var0);
         if (var5.c() < 0.0D) {
            return -1.0D;
         } else {
            var5 = com.aspose.cells.a.c.zk.e(var0, var2);
            if (var5.c() < 0.0D) {
               return -1.0D;
            } else {
               double var6 = var5.c();
               if (var0.getYear() == 1900 && var0.getMonth() == 3 && var0.getDay() == 1) {
                  ++var6;
               }

               return var6;
            }
         }
      }
   }

   static int a(Object var0, int var1) {
      String var2 = com.aspose.cells.b.a.zr.a(var0);
      com.aspose.cells.b.a.g.a.ze var3 = new com.aspose.cells.b.a.g.a.ze("^-?\\d+$");
      if ("".equals(var2)) {
         return var1;
      } else if (var3.d(var2)) {
         int var4 = com.aspose.cells.b.a.zo.a(var2);
         return var4;
      } else {
         return var1;
      }
   }

   static com.aspose.cells.b.a.b.zg a(String var0, float var1, int var2) {
      try {
         return new com.aspose.cells.b.a.b.zg(var0, var1, var2);
      } catch (Exception var5) {
         com.aspose.cells.a.d.zfq var4 = com.aspose.cells.a.c.zn.a(var0, var2);
         return new com.aspose.cells.b.a.b.zg(var0, var1, var4.g());
      }
   }

   static com.aspose.cells.b.a.b.zg a(com.aspose.cells.b.a.b.zg var0) {
      return a(var0.g(), var0.h(), var0.k());
   }

   public static com.aspose.cells.b.a.b.zt a(zn var0, String var1, com.aspose.cells.b.a.b.zg var2, com.aspose.cells.b.a.b.zs var3) {
      com.aspose.cells.b.a.b.zt var4 = new com.aspose.cells.b.a.b.zt((float)var3.b(), (float)var3.c());
      return a(var0, var1, var2, var4);
   }

   public static com.aspose.cells.b.a.b.zt a(zn var0, String var1, com.aspose.cells.b.a.b.zg var2, com.aspose.cells.b.a.b.zt var3) {
      int var4 = var2.d();
      if (var1 != null && var1.length() != 0) {
         com.aspose.cells.b.a.b.zv var5 = new com.aspose.cells.b.a.b.zv(com.aspose.cells.b.a.b.zv.c());
         var5.b(var5.d() | 2048);
         com.aspose.cells.b.a.b.zt var6 = var0.a(var1, var2, var3, var5);
         return var6;
      } else {
         return new com.aspose.cells.b.a.b.zt(0.0F, (float)var4);
      }
   }

   static boolean a(com.aspose.cells.b.a.b.zj var0, com.aspose.cells.b.a.b.zj var1) throws Exception {
      Object var2 = null;
      Object var3 = null;
      if (var0 instanceof com.aspose.cells.b.a.b.za && var1 instanceof com.aspose.cells.b.a.b.b.zf || var0 instanceof com.aspose.cells.b.a.b.b.zf && var1 instanceof com.aspose.cells.b.a.b.za) {
         return false;
      } else {
         byte[] var6;
         byte[] var7;
         if (var0 instanceof com.aspose.cells.b.a.b.b.zf && var1 instanceof com.aspose.cells.b.a.b.b.zf) {
            var6 = var0.f;
            var7 = var1.f;
         } else {
            com.aspose.cells.b.a.d.zh var4 = new com.aspose.cells.b.a.d.zh();
            com.aspose.cells.b.a.d.zh var5 = new com.aspose.cells.b.a.d.zh();
            var0.a((com.aspose.cells.b.a.d.zm)var4, ImageFormat.getBmp());
            var1.a((com.aspose.cells.b.a.d.zm)var5, ImageFormat.getBmp());
            var6 = var4.m();
            var7 = var5.m();
            var4.a();
            var5.a();
         }

         if (var6.length != var7.length) {
            return false;
         } else {
            for(int var8 = 0; var8 < var6.length; ++var8) {
               if (var6[var8] != var7[var8]) {
                  return false;
               }
            }

            return true;
         }
      }
   }

   public static double a(String var0, zxx var1) {
      zhm var2 = var1.h();
      Object var3 = var2.parseObject(var0);
      return var3 != null ? (Double)var3 : 0.0D;
   }

   public static int a(zn var0, com.aspose.cells.b.a.b.zg var1) {
      boolean var2 = false;
      if (var1 != null) {
         int var3 = a((double)var0.a().a(var1));
         int var4 = c((double)((float)var3 * 0.2F));
         return var4 < 2 ? 2 : var4;
      } else {
         return 0;
      }
   }

   static ArrayList a(String var0, Font var1, boolean var2) {
      ArrayList var3 = new ArrayList();
      boolean var4 = false;
      var4 = zar.b(var0);
      if (!var4 && !zar.a(var0) && !var2) {
         return var3;
      } else {
         com.aspose.cells.b.a.g.a.ze var5 = new com.aspose.cells.b.a.g.a.ze("\\n");
         String[] var6 = var5.c(var0);
         zot var8;
         if (var6.length > 1) {
            for(int var18 = 0; var18 < var6.length; ++var18) {
               if (!"".equals(var6[var18])) {
                  ArrayList var19 = a(var6[var18], var1, true);
                  com.aspose.cells.b.a.a.ze.a(var3, (Collection)var19);
               } else if ("".equals(var6[var18]) && var18 == var6.length - 1) {
                  break;
               }

               if (var18 != var6.length - 1) {
                  var8 = new zot();
                  var8.a = "\n";
                  var8.b = var1;
                  com.aspose.cells.b.a.a.ze.a(var3, (Object)var8);
               }
            }

            return var3;
         } else {
            if (var0 != null && !"".equals(var0)) {
               var4 = zar.b(var0);
               if (!var4 && !zar.a(var0)) {
                  zot var17 = new zot();
                  var17.a = var0;
                  var17.b = var1;
                  com.aspose.cells.b.a.a.ze.a(var3, (Object)var17);
               } else {
                  zcm var7 = new zcm();
                  var8 = new zot();
                  var8.a = var0;
                  var8.b = var1;
                  com.aspose.cells.b.a.a.ze.a(var3, (Object)var8);
                  var7.a(var3, var4);
                  zgd.a(var3, var4);

                  for(int var9 = 0; var9 < var3.size(); ++var9) {
                     zot var10 = (zot)var3.get(var9);
                     if (com.aspose.cells.b.a.g.a.ze.b(var10.a, a, 66)) {
                        String var11 = var10.a;
                        char[] var12 = var11.toCharArray();
                        var11 = "";
                        char[] var13 = var12;
                        int var14 = var12.length;

                        for(int var15 = 0; var15 < var14; ++var15) {
                           char var16 = var13[var15];
                           var11 = var11 + var16;
                        }

                        var10.a = var11;
                     }

                     if (var10.a.indexOf(40) >= 0) {
                        var10.a = var10.a.replace('(', ')');
                     } else if (var10.a.indexOf(41) >= 0) {
                        var10.a = var10.a.replace(')', '(');
                     }
                  }
               }
            }

            return var3;
         }
      }
   }

   static void a(ArrayList var0, zahq var1, com.aspose.cells.b.a.b.zg var2, Color var3, zagt var4) {
      for(int var5 = 0; var5 < var0.size(); ++var5) {
         zot var6 = (zot)var0.get(var5);
         var1.a(var6.a, var2, var3, var4, 2);
      }

   }
}
